/*
 * DA04.c
 *
 * Created: 3/29/2014 3:15:18 PM
 *  Author: mummm2
 */ 


#define F_CPU 8000000UL 
#include <avr/io.h>
#include <util/delay.h>

int main ()
{
	//Initilize all registers and values as needed
	unsigned char k;
	DDRD = 0b01100000;   	 //PD5,6 are outputs
	DDRB = 0b00001000;   	 //PB3 is output
	//Phase Correct PWM, COM bits are set to non-inverted
	TCCR0A = (1<<COM0A1) | (0<<COM0A0) | (1<<COM0B1) | (0<<COM0B0) | (0<<WGM01) | (1<<WGM00);
	TCCR0B = (0<<WGM02) | (1<<CS02) | (0<<CS01) | (0<<CS00); //N = 256
	//Phase Correct PWM, COM bits are set to non-inverted
	TCCR2A = (1<<COM2A1) | (0<<COM2A0) | (0<<WGM21) | (1<<WGM20);
	TCCR2B = (0<<WGM22) | (1<<CS22) | (0<CS21) | (0<<CS20); //N = 64
	
	/*
	Rotate the values of the output compare so that there is different colors 
	affects on the RGB LED. 
	*/
	while(1){
		k = 1;
		while (k != 0 ){
			OCR0A = k;    		 
			OCR0B = k+100;   	 
			OCR2A = k+200;
			_delay_ms(25);    
			k++;
		}
		k = 1;		
		while (k != 0 ) {
			OCR0A = k+100;
			OCR0B = k+200;
			OCR2A = k;
			_delay_ms(25);    
			k++;
		}
		k=1;
		while (k != 0 ){
			OCR0A = k+200;
			OCR0B = k;
			OCR2A = k+100;
			_delay_ms(25);
			k++;
		}
	}

	return 0;
}
